<template>
  <div class="home-main-main" style="height: 340px;">
        <div style="display: flex;">
            <div @click="switchCom(item, index)" :class="[active == index ? 'active1' : '']" class="tabs1"
            v-for="(item, index) in data">
            <div>{{ item.name }}</div>
            </div>
        </div>
        <component :is="comId"></component>
    </div>
</template>

<script setup>
import { ref , reactive} from 'vue'
import R1 from '../DataBase/report-1.vue'
import R2 from '../DataBase/report-2.vue'
const comId = ref(R1)
const active = ref(0)

const switchCom = (item, index) => {
  comId.value = item.com
  active.value = index
}

const data = reactive([
  {
    name: '行业报告',
    com: R1
  },
  {
    name: '热点研究',
    com: R2
  }
])
</script>

<style>
.active1{
    background-color: orange;
    color: white;
}
.tabs1{
    height: 30px;
    line-height: 30px;
    font-weight: 800;
    border: 1px solid grey;
    padding: 0 20px 0 20px;
    border-radius: 30px;
    cursor: pointer;
    margin-right: 40px;
    margin-bottom: 15px;
}
</style>